/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.lacibMusic.dao;

import br.com.lacibMusic.entidades.*;
import java.util.Date;
import java.util.List;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.Query;

/**
 *
 * @author alanmlira
 */
public class MusicaDAO {

    private EntityManager em = FabricaEntityManager.obterFactory().createEntityManager();


    public List<Musica> obterDisco(Class<Musica> classe, Disco disco) {
         String query = classe.getSimpleName() + ".findByDisco";
        final Query q = em.createNamedQuery(query);
        q.setParameter("disco", disco);
        return q.getResultList();
    }
    
    public List<Musica> obterPorNome(Class<Musica> classe, String nome) {
         String query = classe.getSimpleName() + ".findByNomeMusica";
        final Query q = em.createNamedQuery(query);
        q.setParameter("nomeMusica", nome);
        return q.getResultList();
    }
    
    public List<Musica> obterPorGeneroMusical(Class<Musica> classe, int id) {
         String query = classe.getSimpleName() + ".findByGeneroMusical";
        final Query q = em.createNamedQuery(query);
        q.setParameter("idMusical", id);
        return q.getResultList();
    }

}
